﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="DeleteOperator.aspx.cs" Inherits="Operator_TransferClients" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<asp:HyperLink ID="AdminOperatorsLink" runat="server" NavigateUrl="Admin.aspx">Администраторская панель</asp:HyperLink>
    →
    <b><asp:Label ID="OperatorsLabel" runat="server" Text="Удалить оператора/передать клиентов" ForeColor="black" Font-Bold="true"  style="font-size: medium;" ></asp:Label></b>
    <br />
    <br />
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataSourceID="SqlDataSourceOperators" DataKeyNames="OperatorId"
        onselectedindexchanged="GridView1_SelectedIndexChanged">
        <Columns>
            <asp:CommandField SelectText="Выбрать для передачи" ShowSelectButton="True" />
            <asp:BoundField DataField="Ф.И.О." HeaderText="Ф.И.О." 
                SortExpression="Ф.И.О." />
            <asp:BoundField DataField="Логин" HeaderText="Логин" SortExpression="Логин" />
            <asp:BoundField DataField="Количество клиентов" 
                HeaderText="Количество клиентов" ReadOnly="True" 
                SortExpression="Количество клиентов" />
        </Columns>
    </asp:GridView>

    <asp:SqlDataSource ID="SqlDataSourceOperators" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>" 
        
        SelectCommand="SELECT Operator.Name AS [Ф.И.О.], aspnet_Users.UserName AS Логин, COUNT(UserProfile.OperatotId) AS [Количество клиентов], Operator.OperatorId FROM Operator INNER JOIN UserProfile ON Operator.OperatorId = UserProfile.OperatotId INNER JOIN aspnet_Users ON Operator.UserId = aspnet_Users.UserId GROUP BY Operator.Name, aspnet_Users.UserName, Operator.OperatorId HAVING (Operator.OperatorId &lt;&gt; @operatorId)">
        <SelectParameters>
            <asp:QueryStringParameter Name="operatorId" QueryStringField="operatorId" />
        </SelectParameters>
    </asp:SqlDataSource>

</asp:Content>

